package PAT.乙.模拟;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * 部分A加B
 *
 * @author yang
 * @date 2021/12/15
 */
public class 部分A加B {

    public static void main(String[] args) throws Exception {
       /* BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        String a = s[0];
        String da = s[1];
        String d = s[2];
        String db = s[3];
        int val = 0;
        int val2 = 0;
        for (int i = 0; i < a.length(); i++) {
            char t = a.charAt(i);
            char t1 = da.charAt(0);

            if (t == t1) {
                val = 10 * val + Integer.parseInt(t+"");
            }
        }

        for (int i = 0; i < d.length(); i++){
            char t = d.charAt(i);
            char t1 = db.charAt(0);

            if (t == t1) {
                val2 = 10 * val2 + Integer.parseInt(t+"");
            }


        }
        System.out.println(val2 + val);*/
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int num1 = 0;
        int num2 = 0;
        while (a != 0) {
            if ((a % 10) == b) num1 = num1 * 10 + b;
            a /= 10;
        }
        while (c != 0) {
            if ((c % 10) == d) num2 = num2 * 10 + d;
            c /= 10;
        }
        System.out.println(num1 + num2);
    }
}
